package com.atguigu.redis.single;

import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * 1.队列
 * 2.阻塞队列
 *  2.1 阻塞对列有没有好的一面
 *  2.2不得不阻塞，你如何管理
 */
public class BlockingQueueDemo {

    public static void main(String[] args) throws InterruptedException {
        //List list =null;
        BlockingQueue<String>blockingQueue =  new ArrayBlockingQueue<>(3);
        System.out.println( blockingQueue.offer("a",2L, TimeUnit.SECONDS));
        System.out.println( blockingQueue.offer("b",2L, TimeUnit.SECONDS));
        System.out.println( blockingQueue.offer("c",2L, TimeUnit.SECONDS));
        System.out.println( blockingQueue.offer("x",2L, TimeUnit.SECONDS));

        System.out.println("==================");

        blockingQueue.take();
        blockingQueue.take();
        blockingQueue.take();



    }

}
